Skip to content

Keep auto channel open from recommending swap providers the node swaps out through - #696

Merged
markettes merged 1 commit into
feat/channel-open-recommendation-historyfrom
feat/block-opening-to-swap-providers
Dec 2, 2026
Merged

markettes merged 1 commit into
feat/channel-open-recommendation-historyfrom
feat/block-opening-to-swap-providers

Conversation

@markettes

Copy link
Copy Markdown
Contributor

Auto channel open could recommend a channel to a swap provider the node itself swaps out through. Our swap-outs are our own payments to that provider, so they would drain the new channel as soon as it opened, and we would pay to open it for nothing.

A node now gets no recommendation to a Loop, 40swap or Spark node while it gives that provider any swap weight, however small. The check runs before every other one and applies to reserved peers too. A provider the node gives no weight is treated like any other peer, and a recommendation already open to a blocked peer expires on the next run. Channel opens created by hand are not stopped.

Provider nodes are listed by pubkey in LOOP_NODE_PUBKEYS, FORTYSWAP_NODE_PUBKEYS and SPARK_NODE_PUBKEYS. Loop and Spark default to their mainnet nodes; 40swap has no default, so it is not blocked until its nodes are listed. Setting a variable replaces its default.

Covered by unit tests and a new e2e scenario, where carol stands in for a 40swap node. The docs no longer present a swap service as the typical reserved peer.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@markettes
markettes added this pull request to stack #663 December 1, 2026 16:49

@lunar-patrol lunar-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Automated security review — no issues found

This PR blocks auto channel-open recommendations to Lightning nodes of swap providers (Loop, 40swap, Spark) that the node currently swaps out through, since its own swap-out payments would drain the new channel. The block list is derived from the same SwapProviderLimits.Weighted() that AutoLiquidityManagementJob uses to actually pick swap providers, so it cannot disagree with real swap routing; pubkey matching is case-insensitive against LND's canonical lowercase hex, so a peer cannot evade it; and the rejection runs before the reserved-peer and cooldown paths with already-open recommendations expiring on the next run via ProcessNode's existing finally block. All inputs to the new logic are operator-controlled (env-parsed pubkey lists) or admin-set (node swap weights) — I found no attacker-reachable path to bypass the check, crash the job, or extract anything.

Reviewed 10 files at 02c74fa. Nothing to report.

Not a guarantee — one diff, no knowledge of your threat model.

🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the swap-provider exclusions in automatic channel recommendations.

No open issues 🎉

What changed in this PR

Prevents automatic channel recommendations to swap providers a node uses, including reserved peers, while leaving manual channel opens unchanged.

Changes:

  • Adds configurable provider pubkey lists and rejects matching peers based on swap weights.
  • Adds unit and end-to-end coverage for blocking providers and expiring recommendations.
  • Updates documentation and UI guidance.
File Description
test/​NodeGuard.Tests/​Services/​SwapOutWarningServiceTests.cs Makes amount assertions culture-aware.
test/​NodeGuard.Tests/​Services/​ChannelOpenInitiatorServiceTests.cs Tests provider rejection, including reserved peers.
test/​NodeGuard.Tests/​Jobs/​AutoChannelOpenJobTests.cs Tests filtering by provider weights.
test/​NodeGuard.Tests/​E2E/​AutoChannelOpenE2ETests.cs Tests recommendation expiry and recovery after weight changes.
src/​Services/​SwapProviderLimits.cs Maps active providers to their node pubkeys.
src/​Services/​ChannelOpenInitiatorService.cs Rejects swap providers before other peer checks.
src/​Pages/​Nodes.razor Clarifies reserved-peer exclusions.
src/​Jobs/​AutoChannelOpenJob.cs Adds provider identity to peer snapshots.
src/​Helpers/​Constants.cs Defines provider pubkeys and environment overrides.
docs/​auto-channel-open.md Documents provider exclusions and configuration.
docker/​e2e/​nodeguard-entrypoint.sh Configures Carol as the test swap provider.

Review effort: Balanced

@markettes
markettes force-pushed the feat/block-opening-to-swap-providers branch from 02c74fa to 766e73e Compare December 2, 2026 16:28

@lunar-patrol lunar-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Automated security review — no issues found

This PR adds a deny-list to the auto channel-open planner: peers whose pubkey appears in the LOOP/FORTYSWAP/SPARK node-pubkey sets are rejected as channel-open recommendations when the node gives that provider any swap weight. The change is purely subtractive — it removes recommendations, never adds or authorizes anything new — and the only inputs are admin-set environment variables (parsed at startup in Constants) and the node's own database weights, none of which an unauthenticated or low-privilege attacker controls. The pubkey lists are compared case-insensitively over full 33-byte pubkeys, so no injection or partial-match path exists. No exploitable defect found.

Reviewed 6 files at 766e73e. Nothing to report.

Not a guarantee — one diff, no knowledge of your threat model.

🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.

@markettes
markettes merged commit bd069ba into main Dec 2, 2026
6 checks passed
@markettes
markettes deleted the feat/block-opening-to-swap-providers branch December 2, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants